package com.king.modules.system.domain.vo.file;

import org.springframework.web.multipart.MultipartFile;

import com.alibaba.fastjson2.annotation.JSONField;
import com.king.common.annotation.MetaData;
import com.king.common.annotation.ObjectData;
import com.king.common.utils.bean.BeanUtils;

import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

/**
 * Description:
 *
 * @author Xander
 * datetime: 2023-03-10 14:21
 */
@Getter
@Setter
@Accessors(chain = true)
@ObjectData("图片上传表单")
public class ImgUploadDto {

    @MetaData(value = "模块类型", nullable = false)
    private String moduleName;

    @MetaData(value = "实体id，选填：没有id可不传", nullable = true)
    private String entityId = "new";

    @MetaData(value = "附件", nullable = false)
    @JSONField(serialize = false)
    private MultipartFile file;

    public static ImgUploadDto newInstance() {
        ImgUploadDto instance = new ImgUploadDto();
        return instance;
    }

    public static ImgUploadDto of(FileUploadDto fileUploadDto) {
        ImgUploadDto instance = newInstance();
//        FastBeanCopyer.getInstance().copy(fileUploadDto, instance);
        BeanUtils.copyProperties(fileUploadDto, instance);
        return instance;
    }
}
